package com.fyl.log;

import com.fyl.log.aop.AsyncLogAdvisor;
import com.fyl.log.aop.AsyncLogMethodInterceptor;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Role;

@Configuration
public class LogConfiguration {

    @Bean
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @ConditionalOnMissingBean
    public AsyncLogMethodInterceptor logMethodInterceptor() {
        return new AsyncLogMethodInterceptor();
    }

    @Bean
    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
    @ConditionalOnMissingBean
    public AsyncLogAdvisor logAdvisor(AsyncLogMethodInterceptor logMethodInterceptor) {
        return new AsyncLogAdvisor(logMethodInterceptor);
    }

}
